<?php

declare(strict_types=1);

namespace App\Service\Logic;

use App\Service\Business\OperateLogBusiness;
use App\Validator\CommonValidator;
use App\Validator\OperateLogValidator;
use Exception;
use Hyperf\Di\Annotation\Inject;

/**
 * 操作日志-逻辑类
 */
class OperateLogLogic extends BaseLogic
{
        #[Inject]
        protected OperateLogBusiness $OperateLogBusiness;

        #[Inject]
        protected CommonValidator $CommonValidator;

        #[Inject]
        protected OperateLogValidator $OperateLogValidator;

        /**
         * 分页
         * @return array
         * @throws Exception
         */
        public function paginate(): array
        {
                $this->CommonValidator->validate($this->request->all(), ['page', 'limit']);
                return $this->OperateLogBusiness->paginate();
        }

        /**
         * 删除
         * @return array
         * @throws Exception
         */
        public function delete(): array
        {
                $this->OperateLogValidator->validate($this->request->all(), ['id']);
                return $this->OperateLogBusiness->delete();
        }

        /**
         * 批量删除
         * @return array
         * @throws Exception
         */
        public function batchDelete(): array
        {
                $this->OperateLogValidator->validate($this->request->all(), ['ids']);
                return $this->OperateLogBusiness->batchDelete();
        }
}